home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / windows / cm95_10.zip / INTERNET.DLL / TEXT / WILAGENT next >
Text File  |  1996-10-29  |  3KB  |  143 lines

  1. AddExtender ("WXSock32i.dll")
  2. IntControl (35, 500, 0, 0, 0)
  3. bOK = @TRUE
  4. sDial     = "<dialupname>"
  5. nMaxRedials= <numredials>
  6. nRedialDelay = 10
  7. sPgmPath  = "<pgmpath>"
  8. sPgmDir   = "<pgmdir>"
  9. bNewHdrs   = <newhdrs>
  10. bSendMail  = <sendmail>
  11. ;bGetMail   = <getmail>
  12. bNewGroups = <newgroups>
  13. bCompact   = <compact>
  14. sErrDesc  = ""
  15. nWait      = 10 ; How many minutes to wait for Agent to finish its work
  16.  
  17.  
  18. ;Dial our host (unless user is on a direct connect)...
  19. hConn = 0
  20. nNumRedials = 0
  21. ;if ((bGetMail || bSendMail) && sDial <> "")
  22. if (bSendMail && sDial <> "")
  23.     :DialIt
  24.     hConn = DUNConnect (sDial)
  25.     nErr = SGetLastErr ()
  26.     if (!hConn)
  27.         switch nErr
  28.         case @SErrNotFound
  29.             sErrDesc = "Couldn't connect to %sDial%: no such dial-up"
  30.             break
  31.         case @SErrBusy
  32.             if (nNumRedials <= nMaxRedial)
  33.                 nNumRedials = nNumRedials + 1
  34.                 Delay (nRedialDelay)
  35.                 goto DialIt
  36.             else
  37.                 sErrDesc = "Couldn't connect to %sDial%: Line busy"
  38.             endif
  39.             break
  40.         case @SErrNoAnswer
  41.             if (nNumRedials <= nMaxRedial)
  42.                 nNumRedials = nNumRedials + 1
  43.                 Delay (nRedialDelay)
  44.                 goto DialIt
  45.             else
  46.                 sErrDesc = "Couldn't connect to %sDial%: No answer"
  47.             endif
  48.             break
  49.         case @SErrVoice
  50.             sErrDesc = "Couldn't connect to %sDial%: A human answered"
  51.             break
  52.         case nErr ; <--default
  53.             sErrDesc = "Couldn't connect to %sDial% - error %nErr%"
  54.         endswitch
  55.         bOK = @FALSE
  56.         goto LogIt
  57.     else
  58.         if (nErr == @SAlready)
  59.             ; We're already connected. Don't hang up when this event is thru...
  60.             hConn = 0 
  61.         endif
  62.     endif
  63. endif
  64.  
  65.  
  66. ; Run Agent & make it do things...
  67. sTitle = ""
  68. if (WinExist ("Free Agent")) then sTitle = "Free Agent"
  69. if (WinExist ("Agent")) then sTitle = "Agent"
  70. if (sTitle <> "")
  71.     WinActivate (sTitle)
  72. else
  73.     DirChange (sPgmDir)
  74.     Run (sPgmPath, "")
  75.     delay (6)
  76.     if (WinExist ("Free Agent")) then sTitle = "Free Agent"
  77.     if (WinExist ("Agent")) then sTitle = "Agent"
  78. endif
  79.  
  80.  
  81. ; Get new headers (if chosen)...
  82. if (bNewHdrs)
  83.     SendKeysTo (sTitle, "!on")
  84.     Delay (10)
  85. endif
  86.  
  87. ; Update the group list (if chosen)...
  88. if (bNewGroups)
  89.     SendKeysTo (sTitle, "!og")
  90.     Delay (10)
  91. endif
  92.  
  93. ; Get new mail (if chosen)...
  94. ;if (bGetMail)
  95. ;    SendKeysTo (sTitle, "???")
  96. ;    Delay (10)
  97. ;endif
  98.  
  99. ; Send outgoing mail/articles (if chosen)...
  100. if (bSendMail)
  101.     SendKeysTo (sTitle, "!op")
  102.     Delay (10)
  103. endif
  104.  
  105. ; Compact the database (if chosen)...
  106. ;if (bCompact)
  107. ;    SendKeysTo (sTitle, "!fc")
  108. ;endif
  109.  
  110.  
  111. ; Wait for nWait minutes, or till user kills off Agent manually...
  112. for n=1 to nWait * 6
  113.     if (WinExist (sTitle))
  114.         Delay (10)
  115.         MouseMove (100+n, 100, "", "")
  116.     endif
  117. next n
  118.  
  119.  
  120. ; If user hit Ctrl+Break, WIL will bring us here...
  121. :Cancel
  122.  
  123. ; Hang up...
  124. :HangUp
  125. if (hConn)
  126.     nRet = DUNDisconnect (hConn)
  127. endif
  128.  
  129.  
  130. ; Log what we did...
  131. :LogIt
  132. if bOK == @TRUE
  133.     sLog = "Ran Agent"
  134. else
  135.     sLog = strcat ("Error attempting to automate Agent:", @CRLF, sErrDesc)
  136. endif
  137.  
  138. CMLogMessage (sLog)
  139. Display (8, "ClockMan95", sLog)
  140. exit
  141.  
  142. ~
  143.